package cn.disignPattern.com.partTwo;

/**
 * Created by Administrator on 2021/6/22 0022.
 */
public class CurrentConditionDisply implements Observer,DisplayElement {

    private float temp;
    private float humidity;
    private Subject weatherData;

    public CurrentConditionDisply(Subject weatherData) {
        this.weatherData = weatherData;
        weatherData.registerObserver(this);
    }

    @Override
    public void display() {
        System.out.println( "CurrentConditionDisply{" +
                "temp=" + temp +
                ", humidity=" + humidity +
                ", weatherData=" + weatherData +
                '}');
    }

    @Override
    public void update(float temp, float humidity, float pressure) {
        this.temp = temp;
        this.humidity = humidity;
        display();
    }
}